/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.project.engineering.pages;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import pl.project.engineering.entities.SerialPortNameEntity;
import pl.project.engineering.services.SerialComPort;

/**
 *
 * @author ksmolnicki
 */
@RequiresAuthentication
public class EditSerialPortName {

  @Property
  private SerialPortNameEntity serialPortNameEntity;

  @Inject
  private SerialComPort serialComPort;

  @InjectPage
  private Configuration configuration;

  @RequiresAuthentication
  Object onActivate() {
    return null;
  }
  
  void setupRender(){
    serialPortNameEntity = new SerialPortNameEntity();
    serialPortNameEntity.setPortName(serialComPort.getPortName());
  }
  
  Object onSuccess(){
    serialComPort.setParameterAndReconnect(serialPortNameEntity.getPortName());
    return configuration;
  }
}
